home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / SummaryPanel.java < prev    next >
Text File  |  1998-10-06  |  4KB  |  122 lines

  1. package com.symantec.itools.frameworks.wizard;
  2.  
  3.  
  4. import java.awt.*;
  5. import com.sun.java.swing.*;
  6. import java.util.Enumeration;
  7. import java.util.Vector;
  8. import java.util.Locale;
  9.  
  10.  
  11. /**
  12.  * @author Symantec Internet Tools Division
  13.  * @version 1.0
  14.  * @since VCafe 3.0
  15.  */
  16.  
  17. public class SummaryPanel extends WizardPanel
  18. {
  19.     public SummaryPanel()
  20.     {
  21.         summaryDescription = new String(summaryPanelResource.getResourceString("SP_Description"));
  22.  
  23.         // Set the SummaryPanel layout to BorderLayout
  24.         setLayout(new BorderLayout());
  25.  
  26.         // Setup the description label
  27.         summaryDescriptionLabel = new JLabel();
  28.         summaryDescriptionLabel.setText(summaryDescription);
  29.           summaryDescriptionLabel.setForeground(SystemColor.controlText);
  30.         summaryDescriptionLabel.setBackground(SystemColor.control);
  31.         insetDescriptionPanel = new BorderPanel(summaryDescriptionLabel, 6, 0, 6, 0, SystemColor.control);
  32.  
  33.         // Panel containing all summaries, is contained within a scrollpane
  34.         summaryContainerPanel = new JPanel();
  35.         summaryContainerPanel.setBounds(10, 10, SUMMARY_WIDTH, 300);
  36.         summaryContainerPanel.setLayout(new GridLayout(0, 1)); // any number of rows within one column
  37.  
  38.         // Put the summaryContainerPanel on a Scrollpane
  39.         scroller = new JScrollPane(summaryContainerPanel);
  40.         insetSummaryPanel = new BorderPanel(scroller, 6, 6, 6, 6, SystemColor.control);
  41.         //scroller.getViewport().add(summaryContainerPanel);
  42.  
  43.         // Panel to hold description and summary
  44.         centerPanel = new JPanel();
  45.         centerPanel.setLayout(new BorderLayout());
  46.         centerPanel.add(insetDescriptionPanel, "North");
  47.         centerPanel.add(insetSummaryPanel, "Center");
  48.         add(centerPanel, "Center");
  49.     }
  50.  
  51.     /**
  52.      * @since VCafe 3.0
  53.      */
  54.  
  55.     public String getPanelTitle()
  56.     {
  57.         return summaryPanelResource.getResourceString("SP_Title");
  58.     }
  59.  
  60.     /**
  61.      * Called by controller before the panel is displayed.
  62.      * Only current panel is called.
  63.      * @since VCafe 3.0
  64.      */
  65.     public void entering()
  66.     {
  67.         Vector summaries = controller.getSummary();
  68.         summaryContainerPanel.removeAll();
  69.  
  70.         // Put summaries into summaryContainerPanel
  71.         Enumeration e1 = summaries.elements();
  72.         while(e1.hasMoreElements())
  73.             addSummary( (Summary) e1.nextElement() );
  74.  
  75.         controller.getWizard().setNextEnabled(false);
  76.  
  77.         invalidate();
  78.         validate();
  79.         repaint();
  80.     }
  81.  
  82.     private void addSummary( Summary s )
  83.     {
  84.         if (summaryElements == null)
  85.             summaryElements = new Vector();
  86.         // if there is a summary panel and either it is preferred or no preference is given,
  87.         // use the summary panel
  88.         if (s.hasPanelSummary() && ( (s.getPreferredSummary() == Summary.PANEL_SUMMARY) ||
  89.                                      (s.getPreferredSummary() == Summary.NO_PREFERENCE) ) )
  90.         {
  91.             summaryContainerPanel.add( s.getPanelSummary() );
  92.             summaryElements.addElement( s.getPanelSummary() );
  93.         }
  94.         // or if there is a string, put it on a JTextArea
  95.         else if ( s.hasStringSummary() )
  96.         {
  97.             JTextArea t = new JTextArea(s.getStringSummary());
  98.                t.setForeground(SystemColor.controlText);
  99.             t.setBackground(SystemColor.window);
  100.  
  101.             summaryContainerPanel.add(t);
  102.             summaryElements.addElement(t);
  103.         }
  104.     }
  105.  
  106.     private JPanel westPanel = null;
  107.     private JPanel centerPanel = null;
  108.     private BorderPanel insetSummaryPanel = null;
  109.     private BorderPanel insetDescriptionPanel = null;
  110.     private JPanel summaryContainerPanel = null;
  111.     private JScrollPane scroller = null;
  112.     private String summaryCaption = null;
  113.     private String summaryDescription = null;
  114.     private JLabel summaryCaptionLabel = null;
  115.     private JLabel summaryDescriptionLabel = null;
  116.     private Vector summaryElements = null;
  117.     private static WizardResourceBundle summaryPanelResource = new WizardResourceBundle("com.symantec.itools.frameworks.wizard.WizardResource", Locale.getDefault());
  118.     private final static int SUMMARY_WIDTH = 550;
  119.  
  120. }
  121.  
  122.